package com.xm.xmapp;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.android.volley.VolleyError;
import com.xm.xmapp.app.MyAppcation;
import com.xm.xmapp.base.BaseActivity;
import com.xm.xmapp.myinterface.DisssmissInterFace;
import com.xm.xmapp.myinterface.GetDataInterFace;
import com.xm.xmapp.request.bean.Get_activity_by_idRequest;
import com.xm.xmapp.response.bean.ResponseActivityById;

public class ActivityListDetailsActivity extends BaseActivity implements OnClickListener {

	private ImageView back;
	private TextView title, message_time, message_title;
	private WebView message_content;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_messagedetails);
	}

	@Override
	public void initView() {
		back = (ImageView) findViewById(R.id.back);
		message_time = (TextView) findViewById(R.id.message_time);
		message_content = (WebView) findViewById(R.id.message_content);
		message_title = (TextView) findViewById(R.id.message_title);
		title = (TextView) findViewById(R.id.title);
	}

	@Override
	public void initData() {
		title.setText("活动消息");
		String id = getIntent().getStringExtra("id");
		getData(id);
	}

	private void getData(String id) {

		Get_activity_by_idRequest requestBean = new Get_activity_by_idRequest();
		requestBean.activity_id = id;
		promptDialog.show();
		MyAppcation.getMyAppcation().getPostData(this, requestBean, new GetDataInterFace<String>() {

			@Override
			public void onResponse(String response) {
				promptDialog.dismiss();
				ResponseActivityById bean = JSON.parseObject(response, ResponseActivityById.class);
				if (bean != null) {
					message_time.setText(bean.modified_on);
					message_content.loadDataWithBaseURL(null, bean.activity_content, "text/html", "utf-8", null);
					message_title.setText(bean.activity_title);
				}

			}
		}, new DisssmissInterFace() {

			@Override
			public void putError(VolleyError error) {
				promptDialog.dismiss();
			}
		});
	}

	@Override
	public void initEvent() {
		back.setOnClickListener(this);
	}

	@Override
	public void onClick(View arg0) {
		switch (arg0.getId()) {
		case R.id.back:
			finish();
			break;
		default:
			break;
		}
	}

}
